package inputstream;

import java.io.FileInputStream;
import java.io.IOException;

public class FileInputStream01 {

    public static void main(String[] args) {
        readFile();
    }

    public static void readFile(){
        String filePath = "D:/IO/demo01.txt";
        FileInputStream fileInputStream = null;
        int readData = 0;
        int counte = 0;
        int counta = 0;
        try{


            fileInputStream  = new FileInputStream(filePath);
            while ((readData = fileInputStream.read()) != -1){
                System.out.print((char)readData);

                char ch= (char)readData;

                if( ch == 'e'){
                        counte++;
                    }
                if(ch=='a'){
                        counta++;
                    }


            }
            System.out.println();
            System.out.println("字母e有"+counte+"个");
            System.out.println("字母a有"+counta+"个");
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }}
